//
//  BQMineTopView.m
//  BeeQuick
//
//  Created by student on 2017/7/10.
//  Copyright © 2017年 BecomeRich. All rights reserved.
//

#import "BQMineTopView.h"

@interface BQMineTopView ()

@property(nonatomic,weak)UIImageView     *avatarImageView;


@end

@implementation BQMineTopView

- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI{
    
    UIImageView *avatarImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"v2_my_avatar-1"]];
    self.avatarImageView =avatarImageView;
    avatarImageView.frame = CGRectMake(0, 0, self.frame.size.width, 150);
    avatarImageView.contentMode = UIViewContentModeScaleAspectFill;
    [self addSubview:avatarImageView];
    UIImageView *headerView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"v2_my_avatar"]];
    headerView.contentMode = UIViewContentModeScaleAspectFill;
    [avatarImageView addSubview:headerView];
    [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(avatarImageView);
    }];
    UIButton *setButton = [[UIButton alloc]init];
    [setButton setImage:[UIImage imageNamed:@"v2_my_settings_icon"] forState:UIControlStateNormal];
    [setButton addTarget:self action:@selector(setButtonAction) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:setButton];
    [setButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(avatarImageView).offset(24);
        make.trailing.equalTo(avatarImageView).offset(-8);
    }];
    UILabel *PhoneLabel = [[UILabel alloc]init];
    PhoneLabel.text = @"1388888888";
    PhoneLabel.textColor = [UIColor whiteColor];
    PhoneLabel.numberOfLines = 0;
    PhoneLabel.font = [UIFont systemFontOfSize:14];
    [avatarImageView addSubview:PhoneLabel];
    [PhoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(avatarImageView);
        make.top.equalTo(headerView.mas_bottom).offset(8);
    }];

}
- (void)setButtonAction{
    if (_topViewBlock != nil) {
        self.topViewBlock();
    }
}

@end
